<?php 
session_start();
if($_GET ['do'] == ''){echo 'Ошибка:435'; exit;} else {$do = htmlspecialchars($_GET ['do']);}
if($_GET ['fr'] == ''){echo 'Ошибка:583'; exit;} else {$fr = htmlspecialchars($_GET ['fr']);}
if($_SESSION['logmit']!=$_GET ['do']){echo 'Ошибка:713'; exit;} else {$log = $_SESSION['logmit'];}
include('/config/config.php');
$put = $pdir.$log."/friends.php";
$put_2 = $pdir.$fr."/config.php";
if(file_exists($put)){include($put);
if(preg_match("/".$fr."/i",$friends)){echo "Ошибка:693"; exit;}
if($fr==$_SESSION['logmit']){echo "Ошибка:768"; exit;}
if (!file_exists($put_2)){echo 'Ошибка:404'; exit;}
$fr = '<li><font size="1">[ <a href="/delfr" rel="'.$fr.'&do=%LOGIN%" id="frdel">Удалить</a> ]</font> <a href="/?prof='.$fr.'">'.$fr.'</a></li>';
$msg = '
<?php 
$friends = \''.$fr.$friends.'\';
?>';
$fs=fopen($put, 'w');
fwrite($fs, $msg);
fclose($fs);
echo "Добавлен";
} else {
if($fr==$_SESSION['logmit']){echo "Ошибка:768"; exit;}
$fr = '<li><font size="1">[ <a href="/delfr" rel="'.$fr.'&do=%LOGIN%" id="frdel">Удалить</a> ]</font> <a href="/?prof='.$fr.'">'.$fr.'</a></li>';
$msg = '
<?php 
$friends = \''.$fr.'\';
?>';
$fs=fopen($put, 'w');
fwrite($fs, $msg);
fclose($fs);
echo "Добавлен";
}
?>